package jiubeirobot.com.robotshop.ui.fragment.shop;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import jiubeirobot.com.robotshop.R;
import jiubeirobot.com.robotshop.base.BaseBean;
import jiubeirobot.com.robotshop.base.BaseFragment;
import jiubeirobot.com.robotshop.bean.StockBean;
import jiubeirobot.com.robotshop.common.LinearItemDecoration;
import jiubeirobot.com.robotshop.ui.activity.shop.CheckOrderActivity;
import jiubeirobot.com.robotshop.ui.adapter.ShopManifestListAdapter;

/**
 * 类描述    : 显示核对订单时的商品清单
 * 创建人    : TheJoker丶豪  on 2017/9/6.
 * 修改人    :
 * 修改时间  :
 * 修改备注  :
 */
public class ShopManifestFragment extends BaseFragment {
    @BindView(R.id.rv_shop_list)
    RecyclerView rvlist;
    @BindView(R.id.iv_close)
    ImageView ivclose;

    ShopManifestListAdapter shopManifestListAdapter;
    private List<StockBean> list = new ArrayList<>();
    CheckOrderActivity checkOrderActivity;


    @Override
    public int pageLayout() {
        return R.layout.fragment_shop_manifest;
    }

    @Override
    public void initTitle() {
        checkOrderActivity = (CheckOrderActivity) getActivity();

    }

    @Override
    public void initView() {
        rvlist.addItemDecoration(new LinearItemDecoration(1));
        rvlist.setLayoutManager(new LinearLayoutManager(getContext()));
        shopManifestListAdapter = new ShopManifestListAdapter(getContext(), list);
        rvlist.setAdapter(shopManifestListAdapter);
    }

    @Override
    public void onSuccess(BaseBean bean, int flag) {

    }


    public void setList(List<StockBean> list) {
        this.list.clear();
        if (list != null) {
            this.list.addAll(list);
        }
        if (shopManifestListAdapter != null) {
            shopManifestListAdapter.notifyDataSetChanged();
        }
    }

    @OnClick({R.id.iv_close})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_close:
                checkOrderActivity.close();
                break;
            default:
                break;
        }
    }
}
